

module.exports = class Logger{
    constructor({delay ={inter:30 * 1000, n: 5}}){
        this.__inter = delay.inter;
        this.__save_log_nums = delay.n;
        // console.log(this.__inter , this.__save_log_nums);

        this.delay = (function(){
            let logs = [];
            let previous = 0;
            // let n = 0;
            return function(...args) {
                logs.push([...args]);
                // n++;
                if(logs.length > this.__save_log_nums){
                    logs.shift();
                }
                // console.log(logs);
                let now = Date.now();
                // t > inter
                // console.log(now - previous, this.__inter);
                if(previous == 0){
                    previous = now;
                } else if ((now - previous )> this.__inter ) {
                   previous = now;
                   console.log("--------delay   logger---------");
                   for(let i = 0; i < logs.length; i++){
                        console.log(...logs[i]);
                   }
                   logs = [];
                }
              };
        }());
    }
}